# -*- coding: utf-8 -*-

from odoo import models, fields, api
from odoo.exceptions import ValidationError
from odoo.tools import float_compare


class PurchaseOrderLine(models.Model):
    _inherit = 'purchase.order.line'
    @api.constrains('product_qty', 'qty_received')
    def check_dates(self):
        for r in self:
           if float_compare(r.qty_received,r.product_qty,precision_digits=0)==1:

            raise ValidationError('%s 收货数量不能大于下单数量' % r.product_id.name)


